﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace SpaceHero.Screens
{
    class LogoScreen
    {
        SpriteFont smallFont;
        Texture2D Logo;
        int? startTime;

        public LogoScreen()
        { 
        
        }

        public void LoadContent(ContentManager content)
        {
            Logo = content.Load<Texture2D>("Logo");
            smallFont = content.Load<SpriteFont>("SmallFont");
        }

        public void Update(GameTime gameTime, StateManager stateManager, KeyboardState keyState, KeyboardState oldKeyState)
        {
            if (!startTime.HasValue)
            {
                startTime = gameTime.TotalGameTime.Seconds;
            }
            else
            {
                if (gameTime.TotalGameTime.Seconds > (startTime.Value + 2))
                    stateManager.state = StateManager.GameStates.MainMenu;
            }

            if ((keyState.IsKeyUp(Keys.Escape) && oldKeyState.IsKeyDown(Keys.Escape)) || (keyState.IsKeyUp(Keys.Space) && oldKeyState.IsKeyDown(Keys.Space)) || (keyState.IsKeyUp(Keys.Enter) && oldKeyState.IsKeyDown(Keys.Enter)))
                stateManager.state = StateManager.GameStates.MainMenu;
        }

        public void Draw(GraphicsDeviceManager graphics, SpriteBatch spriteBatch)
        {
            spriteBatch.Begin();
            spriteBatch.Draw(Logo, new Rectangle(0, 0, graphics.GraphicsDevice.Viewport.Width, graphics.GraphicsDevice.Viewport.Height), Color.White);
            spriteBatch.End();
        }
    }
}
